import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_getx/SnakebarExample/snakebarExample.dart';
import 'package:get/get.dart';

class DialogExample extends StatefulWidget {
  const DialogExample({super.key});

  @override
  State<DialogExample> createState() => _DialogExampleState();
}

class _DialogExampleState extends State<DialogExample> {
  final count = 0.obs;

  void increment() {
    count.value++;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("GetX Dialog"),
        centerTitle: true,
      ),
      body: Center(
        child: ListView(
          padding: const EdgeInsets.all(20),
          children: [
            Obx(
              () => Text("count值为：${count.value}"),
            ),
            ElevatedButton.icon(
              onPressed: () {
                increment();
              },
              icon: const Icon(Icons.add),
              label: const Text("加一点"),
            ),
            ElevatedButton(
              onPressed: () {
                Get.snackbar(
                  "Snackbar 标题", "欢迎使用Snackbar",
                  // colorText: Colors.pink,
                  duration: const Duration(
                    milliseconds: 5000,
                  ),
                  // snackPosition: SnackPosition.BOTTOM,
                  // titleText: Text("hahah"),
                  // messageText: Text("aslkdjlsakjdla s "),
                  icon: const Icon(Icons.ac_unit_sharp),
                  shouldIconPulse: false,
                  // maxWidth: 300,
                  // margin: const EdgeInsets.all(10),
                  // padding: const EdgeInsets.all(10),
                  // borderRadius: 50,
                  // borderWidth: 10,
                  // borderColor: Colors.greenAccent,
                  // leftBarIndicatorColor: Colors.red,
                  // boxShadows: [
                  //   const BoxShadow(
                  //     color: Colors.blue,
                  //     offset: Offset(10, 20),
                  //     spreadRadius: 20,
                  //     blurRadius: 10,
                  //   ),
                  // ],
                  // backgroundGradient: const LinearGradient(colors: [
                  //   Colors.red,
                  //   Colors.black,
                  // ]),
                  mainButton: TextButton(
                    onPressed: () {},
                    child: const Text(
                      "确认",
                      style: TextStyle(
                        color: Colors.greenAccent,
                      ),
                    ),
                  ),
                  onTap: (a) {
                    if (kDebugMode) {
                      print("点击了$a");
                    }
                  },
                  // isDismissible: false,
                  // dismissDirection: DismissDirection.horizontal,
                  // forwardAnimationCurve: Curves.bounceInOut,
                  // overlayBlur: 100,
                  snackbarStatus: (s) {
                    if (kDebugMode) {
                      print(s);
                    }
                  },
                );
              },
              child: const Text(
                "显示 Snackbar",
              ),
            ),
            ElevatedButton(
              onPressed: () {
                Get.defaultDialog(
                  title: "是否上车",
                  titleStyle: const TextStyle(
                    color: Colors.red,
                  ),
                  middleText: "大家坐好，准备开车了",
                  middleTextStyle: const TextStyle(color: Colors.red),
                  barrierDismissible: true,
                );
              },
              child: const Text("显示Dialog"),
            ),
            ElevatedButton(
              onPressed: () {
                Get.bottomSheet(
                  Wrap(
                    children: [
                      ListTile(
                        leading: const Icon(Icons.wb_sunny_outlined),
                        title: const Text("白天模式"),
                        onTap: () {
                          Get.changeTheme(
                            ThemeData.light(),
                          );
                          Get.back();
                        },
                      ),
                      ListTile(
                        leading: const Icon(Icons.wb_sunny),
                        title: const Text("黑夜模式"),
                        onTap: () {
                          Get.changeTheme(
                            ThemeData.dark(),
                          );
                          Get.back();
                        },
                      ),
                    ],
                  ),
                );
              },
              child: const Text("切换主题"),
            ),
            ElevatedButton(
              onPressed: () {
                Get.to(
                  () => const SnackbarExample(),
                  fullscreenDialog: true,
                  transition: Transition.leftToRightWithFade,
                  duration: const Duration(
                    milliseconds: 2000,
                  ),
                  curve: Curves.bounceInOut,
                  arguments: "askd;adka;s",
                )?.then((value) {
                  if (kDebugMode) {
                    print("收到了你还的数据？$value");
                  }
                });
              },
              child: const Text("跳转Snackbar"),
            ),
            ElevatedButton(
              onPressed: () {
                Get.toNamed(
                  "/snack-bar",
                  arguments: "askd;adka;s",
                )?.then((value) {
                  if (kDebugMode) {
                    print("收到了你还的数据？$value");
                  }
                });
              },
              child: const Text("跳转Snackbar"),
            ),
            ElevatedButton(
              onPressed: () {
                Get.toNamed(
                  "/getXController",
                  arguments: "askd;adka;s",
                )?.then((value) {
                  if (kDebugMode) {
                    print("收到了你还的数据？$value");
                  }
                });
              },
              child: const Text("跳转GetXController"),
            ),
            ElevatedButton(
              onPressed: () {
                Get.toNamed(
                  "/getXControllerWorkers",
                  arguments: "askd;adka;s",
                )?.then((value) {
                  if (kDebugMode) {
                    print("收到了你还的数据？$value");
                  }
                });
              },
              child: const Text("跳转GetXControllerWorkers"),
            ),
          ],
        ),
      ),
    );
  }
}
